{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "595308c8-9feb-4b6c-bfea-922ef8b031e8",
   "metadata": {},
   "source": [
    "## The Text format\n",
    "### Example: converting the TINY SHAKESPEARE dataset into the \"Text\" format"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "546f924a-df45-48ba-849f-51cf919aca9d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Text len:  1115394\n"
     ]
    }
   ],
   "source": [
    "import urllib.request\n",
    "URL = \"https://raw.githubusercontent.com/karpathy/char-rnn/master/data/tinyshakespeare/input.txt\"\n",
    "shakespeare_data = \"\".join([line.decode('utf-8') for line in urllib.request.urlopen(URL)])\n",
    "print(\"Text len: \", len(shakespeare_data))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3b84ca7b-d344-4ebe-9751-22d3e1482a3b",
   "metadata": {},
   "outputs": [],
   "source": [
    "text_format = {\n",
    "    \"text\": [shakespeare_data]\n",
    "}\n",
    "\n",
    "from datasets import Dataset\n",
    "dataset = Dataset.from_dict(text_format)\n",
    "dataset.push_to_hub(\"<HUGGING_FACE_DATASET_REPO>\", token=\"<HUGGING_FACE_TOKEN>\") # Example of a dataset repo 'test/test_dataset'"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.18"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
